//
//  AdvanceViewController.m
//  DebugDemo
//
//  Created by XFB on 2018/11/8.
//  Copyright © 2018年 ZhouCheng. All rights reserved.
//

#import "AdvanceViewController.h"
#import "AdvanceMVVMViewController.h"

#import "YFGoldPriceChatView.h"
#import "YFLineTipView.h"
#import "GoldPriceTrendModel.h"

@interface AdvanceViewController ()

/* 数据源 */
@property (nonatomic, strong) NSMutableArray *dataSource;
@property (nonatomic, strong) NSMutableArray *verticalArray;
@property (nonatomic, strong) NSMutableArray *horizontalArray;

@end

@implementation AdvanceViewController

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = YES;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setupBasicSet];
    [self setupUI];
}

- (void)setupBasicSet {
    self.view.backgroundColor = [UIColor orangeColor];
 
}

- (void)setupUI {
    YFGoldPriceChatView *chartView = [[YFGoldPriceChatView alloc] initWithFrame:CGRectMake(0, 88, ScreenW, 300)];
    [self.view addSubview:chartView];
    chartView.allPointCount = 28;

    chartView.verticalDateArray = self.verticalArray;
    chartView.horizontalDateArray = self.horizontalArray;
//    chartView.horizontalDateArray = @[@"00:00",@"04:00",@"08:00",@"12:00",@"16:00",@"20:00",@"24:00"];

    chartView.dataArray = self.dataSource;
}

- (NSMutableArray *)dataSource {
    if (!_dataSource) {
        NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"ComplaintData.plist" ofType:nil];
        NSArray *plistArray = [NSArray arrayWithContentsOfFile:plistPath];
        NSMutableArray *array = @[].mutableCopy;
        NSMutableArray *vArray = @[].mutableCopy;
        NSMutableArray *hArray = @[].mutableCopy;
        for (NSDictionary *dict in plistArray) {
            GoldPriceTrendModel *model = [GoldPriceTrendModel mj_objectWithKeyValues:dict];
            [vArray addObject:model.all_num];
            [hArray addObject:model.days];
            [array addObject:model];
        }
        _dataSource = [array mutableCopy];
    }
    return _dataSource;
}

- (NSMutableArray *)verticalArray {
    if (!_verticalArray) {
        NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"ComplaintData.plist" ofType:nil];
        NSArray *plistArray = [NSArray arrayWithContentsOfFile:plistPath];
        NSMutableArray *vArray = @[].mutableCopy;
        for (NSDictionary *dict in plistArray) {
            GoldPriceTrendModel *model = [GoldPriceTrendModel mj_objectWithKeyValues:dict];
            [vArray addObject:model.all_num];
        }
        _verticalArray = [vArray mutableCopy];
    }
    return _verticalArray;
}

- (NSMutableArray *)horizontalArray {
    if (!_horizontalArray) {
        NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"ComplaintData.plist" ofType:nil];
        NSArray *plistArray = [NSArray arrayWithContentsOfFile:plistPath];
        NSMutableArray *hArray = @[].mutableCopy;
        for (NSDictionary *dict in plistArray) {
            GoldPriceTrendModel *model = [GoldPriceTrendModel mj_objectWithKeyValues:dict];
            [hArray addObject:model.days];
        }
        _horizontalArray = [hArray mutableCopy];
    }
    return _horizontalArray;
}

@end
